package exam.xiecheng.autumn.S4;

import java.util.*;

public class Main {

    public static int n;
    public static int[] nums;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        System.out.println(solution());
    }

    private static int solution() {
        List<Integer> target = new ArrayList<>();
        int soft = getSoftValue(target);
        if (soft == 0 || target.size() > 2)
            return soft;
        if (target.size() == 1) {
            int k = target.get(0);
            int res = soft;
            if (k == 0) {
                return getSoftValue(0, nums[1]);
            } else if (k == nums.length - 2) {
                return getSoftValue(nums.length-1, nums[nums.length-2]);
            } else {
//                if ((nums[k-1] <= nums[k] && nums[k] <= nums[k+1]) || (nums[k-1] >= nums[k] && nums[k] >= nums[k+1]))
                return getSoftValue(k, (nums[k-1] + nums[k+1]) / 2);
            }
        } else {
            int a = target.get(0);
            int b = target.get(1);
            if (a + 1 != b)
                return soft;
            if ((nums[a] < nums[b] && nums[b] < nums[b+1]) || (nums[a] > nums[b] && nums[b] > nums[b+1]))
                return soft;
            return getSoftValue(b, nums[a]);
        }
    }

    private static int getSoftValue(List<Integer> target) {
        int res = 0;
        for (int i=0; i<n-1; ++i) {
            int v = Math.abs(nums[i] - nums[i+1]);
            if (target != null) {
                if (v > res) {
                    target.clear();
                    target.add(i);
                    res = v;
                } else if (v == res) {
                    target.add(i);
                }
            } else {
                res = Math.max(res, v);
            }
        }
        return res;
    }

    private static int getSoftValue(int t, int v) {
        int res = 0;
        int origin = nums[t];
        nums[t] = v;
        for (int i=0; i<n-1; ++i) {
            res = Math.max(res, Math.abs(nums[i] - nums[i+1]));
        }
        nums[t] = origin;
        return res;
    }
}